package com.lswms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.lswms.common.service.impl.CrudServiceImpl;
import com.lswms.dao.SysConfigDao;
import com.lswms.dto.SysConfigDTO;
import com.lswms.entity.SysConfigEntity;
import com.lswms.entity.YnLotteryTicketActivityEntity;
import com.lswms.service.SysConfigService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-06-20
 */
@Service
public class SysConfigServiceImpl extends CrudServiceImpl<SysConfigDao, SysConfigEntity, SysConfigDTO> implements SysConfigService {

    @Override
    public QueryWrapper<SysConfigEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<SysConfigEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }

    /**
     * 查询配置信息
     */
	@Override
	public String queryConfig(String code) {
		QueryWrapper<SysConfigEntity> wrapper = new QueryWrapper<SysConfigEntity>();
		wrapper.eq("sys_code", code);
		SysConfigEntity config = baseDao.selectOne(wrapper);
		if(config != null){
			return config.getSysValue();
		}
		return "";
	}


}